package com.cqrcb.cloud.handler;

import com.alibaba.cloud.sentinel.rest.SentinelClientHttpResponse;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.cqrcb.cloud.entity.api.req.Q;
import com.cqrcb.cloud.entity.api.res.R;
import com.cqrcb.cloud.entity.quota.io.MultiQuotaCtrlMarketMainIO;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;

public class BlockExceptionUtil {
//    public static R deduction2(Q<MultiQuotaCtrlMarketMainIO> q, BlockException ex) {
//        System.out.println("Oops: " + ex.getClass().getCanonicalName());
//        return R.fail("被限流或降级了");
//    }
    public static SentinelClientHttpResponse handleException(HttpRequest request,
                                                             byte[] body,
                                                             ClientHttpRequestExecution execution,
                                                             BlockException ex) {
        System.out.println("Oops: " + ex.getClass().getCanonicalName());
        return new SentinelClientHttpResponse("Oops");
    }
}
